package com.bj.zspace.grpc.zipkin;

import brave.Tracing;
import brave.grpc.GrpcTracing;
import brave.rpc.RpcTracing;
import zipkin2.reporter.brave.AsyncZipkinSpanHandler;
import zipkin2.reporter.okhttp3.OkHttpSender;

/**
 * zipkin 需要的组件配置
 */
public class ZipkinBraveTracing {


    public static OkHttpSender sender = OkHttpSender.create("http://127.0.0.1:9411/api/v2/spans");

    public static AsyncZipkinSpanHandler spanHandler = AsyncZipkinSpanHandler.newBuilder(sender).build();

    public static final GrpcTracing create(String serviceName) {
        return   GrpcTracing.newBuilder(
            RpcTracing.newBuilder(Tracing.newBuilder().localServiceName(serviceName)
                .addSpanHandler(spanHandler).build()).build()
        ).build();
    }

}
